package com.gc.asm.client;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;


public  class AsmFileUtils {

    /**
     * InputStream（文件流）转换文件（File）
     * @param inputStream   需要转换的文件流
     * @param outFilePrefix 输出文件的前缀
     * @param outFileSuffix 输出文件的后缀
     * @return
     */
    public static File InputStreamToFile(InputStream inputStream, String outFilePrefix, String outFileSuffix) {
        try {
            File outFile = File.createTempFile(outFilePrefix, outFileSuffix);
            FileUtils.copyInputStreamToFile(inputStream, outFile);
            return outFile;
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return null;
    }
}
